Skip to content

Conversation

AndreasArvidsson
Copy link
Member

@AndreasArvidsson AndreasArvidsson commented Aug 1, 2024

related #2618
revives #1832

vscode quick fix import and auto import appears to be doing the right thing in regards to type only or runtime imports. Imports organize or imports fix unfortunately do not convert a runtime import to a type import if it's only used as a type. We probably need to rely on the linter to do that part for us.

Checklist

  • [/] I have added tests
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson AndreasArvidsson changed the title ConsistentTypeImports rule consistent-type-imports rule Aug 1, 2024
@pokey
Copy link
Member

pokey commented Aug 1, 2024

When you save, shouldn't the eslint fixer correct it tho?

@AndreasArvidsson
Copy link
Member Author

When you save, shouldn't the eslint fixer correct it tho?

Yes if you have that enabled of course. I was just testing what vscode by itself would do.

Copy link
Member

@phillco phillco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, reviewed the base commit and a bit of the automatic changes

tbh kind of surprised this is a linter feature not a compiler one, given the benefits for transpilation

@AndreasArvidsson AndreasArvidsson added this pull request to the merge queue Aug 2, 2024
Merged via the queue into main with commit 6b87f2f Aug 2, 2024
@AndreasArvidsson AndreasArvidsson deleted the consistentTypeImports branch August 2, 2024 06:45
@auscompgeek
Copy link
Member

tbh kind of surprised this is a linter feature not a compiler one, given the benefits for transpilation

TypeScript's verbatimModuleSyntax config enforces types are only imported with import type. The lint rule provides an autofixer though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants